

var pageContext = new PageContextDatatable(settings||{});
pageContext.formInit = function(layero){
}
pageContext.toAdd = function(option){
	var action = window.global.getFinalUrl(pageContext.setting.toAddUrl);
	load(action,"page-content",true,"新增"+pageContext.modelName,function(){
		
	});
}
pageContext.toDetail = function(id,data){
	var action = window.global.getFinalUrl(pageContext.setting.toDetailUrl);
	action = window.global.addPara(action,"id",id,true)
	load(action,"page-content",true,pageContext.modelName+"详情",function(){
		
	});
}
pageContext.toUpdate = function(id,data){
	var action = window.global.getFinalUrl(pageContext.setting.toUpdateUrl);
	action = window.global.addPara(action,"id",id,true)
	load(action,"page-content",true,"修改"+pageContext.modelName,function(){
		
	});
}
pageContext.resetFormAfter = function (){
	$("#searchForm select").val(null).trigger("change"); 
}
pageContext.additionalRenderPerColumn1 = function(record, rowIndex, colIndex, tdObj, trObj, options){//搜索
	   var name = '';
	   var render = options.columnsModel[colIndex].render;
	   if(render!=''){
		  name = render;
	   }else{
		  var index = options.columnsModel[colIndex].index;
		  if(index!=''){
			 name = index;
		   }
	   }
	   if(name!='' && name!=undefined){
		   tdObj.attr("id",trObj.attr("id")+"_"+name);
	   }
	   var headers = pageContext.gridObj.getGridHeaderObject();
	   var h = headers[colIndex];
	   var strs = $(h).attr("class");
	   if(strs){
		   var list = strs.split(" ");
		   var len = list.length;
		   for(var i=0;i<len;++i){
			   var clas = list[i];
			   if(clas.indexOf("hidden">-1)){
				   tdObj.addClass(clas);
			   }
		   }
	   }
	   console.log(pageContext.gridObj.getGridHeaderObject())
	   console.log(colIndex)
}
pageContext.afterRenderGrid = function(data){
	    var layero = $("#"+pageContext.setting.tableId+"_wrapper");
		layero.find('select[novalid!="true"]').each(function(){
			var novalid = $(this).attr("noconvert");
			if(novalid!="true"){
				var $span = layero.find(this).select2({
		            language: "zh-CN"})
		            .next("span")
		            ;
			   $span.css("padding","0px")
	            .css("min-width",$span.css("width")).css("width", "")
	            .css("border","0px").css("height","26px").css("margin-bottom","5px")
	            .removeClass("form-control").addClass("form-control")
	            .removeClass("form-control-min").addClass("form-control-min");
			}
		  });
}
jQuery(function($) {
	 $(document).find("input").each(function(){
		 $(this).attr("autocomplete","off");
	 });
   var layero = $("#searchForm");
	layero.find('select[novalid!="true"]').each(function(){
		var novalid = $(this).attr("noconvert");
		if(novalid!="true"){
			var $span = layero.find(this).select2({
	            language: "zh-CN"
		            ,matcher:select2Matcher})
	            .next("span")
	            ;
		}
	  });
	pageContext.init();
}); 
function test(){
	var setting = {
			fixedColumns: true,
			  "columns": [
				  {  
		                className: "center",  
		                orderable : false,    
		                bSortable : false,  
		                data : "id",   
		                width : "50px",  
		                //render : selectFunc
		            }, {  
		                className: "center",  
		                data : "id",  
		                bSortable : false,  
		                width : "50px",  
		                render : function(data, type, row, meta) {  
		                    // 显示行号  
		                    var startIndex = meta.settings._iDisplayStart;  
		                    return startIndex + meta.row + 1;  
		                }  
		            },  
		            { "data": "name"},
		            { "data": "label",className : "ellipsis",render :function (data, type, row, meta) {
	                    data = data||"";
	                    return '<span title="' + data + '">' + data + '</span>';
	             }},
		            { "data": "val" ,className : "ellipsis",render :function (data, type, row, meta) {
	                    data = data||"";
	                    return '<span title="' + data + '">' + data + '</span>';
	             }},
		            { "data": "categoryName" },
		            { "data": "validCreateDt" }
		            ,{  data : "id",  
		                bSortable : false,  
		                render : function(data, type, row, meta) {  
							var content= pageContext.getPingPuOperBtn(row.id,row.name,row) + pageContext.getOperBtn(row.id,row.name,row);
		                    return content;  
		                }  
		            }
		        ]
	    } ;
	console.log(pageContext.getClomuns())
}
